import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
import { SpinService } from 'src/app/core/service/store/spin/spin.service';
import { fnCheckForm } from 'src/app/utils/tools';

@Component({
  selector: 'app-login-form',
  templateUrl: './login-form.component.html',
  styleUrls: ['./login-form.component.less'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class LoginFormComponent implements OnInit {

  validateForm!: FormGroup;
  constructor(private fb: FormBuilder,private spinService:SpinService,private router:Router) { }

  submitForm(): void {
    console.log('Submit Form',fnCheckForm)
    if (!fnCheckForm(this.validateForm)) {
      return;
    }
    this.spinService.setCurrentGolbalSpinStore(true)
    setTimeout(() => {
      this.router.navigateByUrl('default')
      this.spinService.setCurrentGolbalSpinStore(false)
    }, 1000);
  }
  ngOnInit(): void {
    this.validateForm = this.fb.group({
      userName: [null ],
      password: [null],
      remember: [null],
    });
  }

}
